<template>
	<view style="width: 700upx;padding: 25upx;overflow:hidden;">
		<rich-text :nodes="agreement"></rich-text>
	</view>
</template>

<script>
	import urlConfig from 'common/config.js';
	export default {
		data() {
			return {
				nodes: [{
					name: 'div',
					attrs: {
						class: 'div-class',
						style: 'line-height: 60px; color: red; text-align:center;'
					},
					children: [{
						type: 'text',
						text: 'Hello&nbsp;uni-app!'
					}]
				}],
				agreement:''
			}
		},
		onLoad() {
			this.type_api()
		},
		methods: {
			type_api() {
				var that = this
				uni.request({
					url: urlConfig.Url + 'login/privacy',
					data:{
						// access_token:uni.getStorageSync('access_token'),
					},
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: (res) => {
						if (res.data.code == 0) {
							var richtext=  res.data.data.text
							const regex = new RegExp('<img', 'gi');
							richtext= richtext.replace(regex, `<img style="max-width: 100%;"`);
							this.agreement = richtext;
						} else if (res.data.code == -1) {	
							uni.reLaunch({
								url:'../disembark/disembark'
							})
						} else {
							uni.showToast({
								title: res.data.msg,
								duration: 2000,
								icon: 'none'
							});
						}
					}
				});
			},
		}
	}
</script>

<style>
	page{
		/* padding-top: 30upx; */
	}
</style>
